<?php
if($_POST['submit_poll']!=true) echo '';
else {
   $poll_name = htmlspecialchars(trim($_POST['poll_name']));
   $poll_descr = htmlspecialchars(trim($_POST['poll_descr']));
   $date_added = time();
   
   $sel_poll = mysql_query('SELECT vapros FROM poll_vaprosi WHERE vapros = "'.$poll_name.'"');
   if(mysql_num_rows($sel_poll) != 0){
      echo '<p class="error">Вече съществува анкета с такова име!</p>';
   } else {
   if(empty($poll_name) || empty($poll_descr)){
      echo '<p class="error">Моля, попълнете ВСИЧКИ полета!</p>';
   } else {
      if(strlen($poll_name)<3){
	     echo '<p class="error">Кратко име на анкетата!</p>';
	  } else {
	     $ins = mysql_query('INSERT INTO poll_vaprosi(vapros, descr, date_added) VALUES("'.$poll_name.'", "'.$poll_descr.'", "'.$date_added.'")');
		 echo '<p class="success">Успешен запис!</p>';
	  }
   }
   }
}
?>